
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <sys/socket.h>
#include <librally.h>

int main()
{
	Err err;
 	int fd;
	int clifd;
	int length;
	struct sockaddr_in addr;
	struct sockaddr_in cliaddr; 
	
	addr.sin_family = AF_INET;
	addr.sin_port = htons(8888);
	addr.sin_addr.s_addr = inet_addr("127.0.0.1");
	memset(&addr.sin_zero, 0, sizeof(addr.sin_zero));

	err = rp_comm_tcp_server_init (&fd, &addr, COMM_BLOCK);
	clifd = rp_comm_accept(fd, &cliaddr, &length);
	
	char *buf = (char *)malloc(8);
	int count;	count = rp_comm_recv(clifd, (void *)buf, 8, 0);
	err = rp_comm_send(clifd, (void *)buf, count);
	close(clifd);
	close(fd);
	free(buf);
	
	exit(0);
}

